import React, { Component } from 'react';

class App extends Component {
  constructor() {
    super();
    this.state = {
      count: 0,
      message: "Hello World"
    }
  }

  render() {
    console.log("App render 函数调用");

    return (
      <div>
        <h2>当前计数：{this.state.count}</h2>
        <button onClick={e => { this.changeCount() }}>+1</button>
        <button onClick={e => this.changeText()}>改变文本</button>
      </div>
    );
  }
  changeCount() {
    this.setState({
      count: this.state.count + 1
    })
  }

  changeText() {
    this.setState({
      message: "你好"
    })
  }

  shouldComponentUpdate(nextProps,nextState) {
    if (this.state.count !== nextState.count) { 
      return true
    }

    return false
  }
}


export default App;